#include "sensorlist.h"

#include <QDebug>

SensorList::SensorList(QObject *parent)
    : QObject{parent}
{
    sm1 = new SensorModel();
    DATA d1;
    d1.name = "sm1";
    d1.value = 1;
    sm1->append(d1);
    sensor.append(sm1);

    sm2 = new SensorModel();
    DATA d2;
    d2.name = "sm2";
    d2.value = 2;
    sm2->append(d2);
    sensor.append(sm2);

    sm3 = new SensorModel();
    DATA d3;
    d3.name = "sm3";
    d3.value = 3;
    sm2->append(d3);
    sensor.append(sm3);
    sensor.append(sm3);

    sm4 = new SensorModel();
    DATA d4;
    d4.name = "sm4";
    d4.value = 4;
    sm4->append(d4);
    sensor.append(sm4);
    sensor.append(sm4);

    timer = new QTimer();
    connect(timer, SIGNAL(timeout()), this, SLOT(update()));
    timer->start(500);
}

const QString &SensorList::getName() const
{
    qDebug()<<"getName"<<name;
    return name;
}

void SensorList::setName(const QString &newName)
{
    qDebug()<<"setName"<<newName;
    if (name == newName)
        return;
    name = newName;
    emit nameChanged();
}

S401Model *SensorList::getS401m() const
{
    return s401m;
}

void SensorList::setS401m(S401Model *newS401m)
{
    if (s401m == newS401m)
        return;
    s401m = newS401m;
    emit s401mChanged();
}

int SensorList::getSensorCount()
{
    qDebug()<<"getSensorCount <<"<<sensor.size();
    return sensor.size();
}

SensorModel *SensorList::getSensor(int index) const
{
    qDebug()<<"get sensor index <<"<<index;
    return sensor.at(index);
}

void SensorList::update()
{
//    qDebug()<<"===========";
}


